package org.lmw.note.widget;

import android.app.DatePickerDialog;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.DatePicker;


/**
 * 重写datePicker 1.只显示 年-月 2.title 只显示 年-月
 * @author lmw
 */
public class MonPickerDialog extends DatePickerDialog{
	
	public MonPickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
		
		super(context, callBack, year, monthOfYear, dayOfMonth);
		
		this.setTitle(year + "年" + (monthOfYear + 1) + "月");
		
		
		((ViewGroup) ((ViewGroup) this.getDatePicker().getChildAt(0)).getChildAt(0)).getChildAt(2).setVisibility(View.GONE);
		
	}
	
	@Override
	public void onDateChanged(DatePicker view, int year, int month, int day) {
		super.onDateChanged(view, year, month, day);
		this.setTitle(year + "年" + (month + 1) + "月");
	}
	
	
	
	/*
	 * 日期选择器 年-月
	 */
//	public void showMonPicker(Date mon,TextView tv) {
//		final Calendar localCalendar = Calendar.getInstance();
//		localCalendar.setTime(mon);
//		MonPickerDialog.OnDateSetListener() {
//					@Override
//					public void onDateSet(DatePicker view, int year,int monthOfYear, int dayOfMonth) {
//						localCalendar.set(1, year);
//						localCalendar.set(2, monthOfYear);
//						mon_date_filter.setText(DateUtils.clanderTodatetime(localCalendar, "yyyy-MM"));
//						adapter.notifyDataSetChanged();
//					}
//				}, localCalendar.get(1), localCalendar.get(2),localCalendar.get(5)).show();
//	}

}